package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeBaseDictionary;
import com.htgd.gardenexpo.dao.GeBaseDictionaryDao;
import com.htgd.gardenexpo.service.GeBaseDictionaryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典表(GeBaseDictionary)表服务实现类
 *
 * @author makejava
 * @since 2021-05-31 13:44:04
 */
@Service("geBaseDictionaryService")
public class GeBaseDictionaryServiceImpl implements GeBaseDictionaryService {
    @Resource
    private GeBaseDictionaryDao geBaseDictionaryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dictionaryId 主键
     * @return 实例对象
     */
    @Override
    public GeBaseDictionary queryById(Integer dictionaryId) {
        return this.geBaseDictionaryDao.queryById(dictionaryId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeBaseDictionary> queryAllByLimit(int offset, int limit) {
        return this.geBaseDictionaryDao.queryAllByLimit(offset, limit);
    }


    @Override
    public List<GeBaseDictionary> getDictionariesByValues(String value,int pageNum, int pageSize) {
        return this.geBaseDictionaryDao.getDictionariesByValues(value,pageNum, pageSize);
    }

    /**
     * 新增数据
     *
     * @param geBaseDictionary 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseDictionary insert(GeBaseDictionary geBaseDictionary) {
        this.geBaseDictionaryDao.insert(geBaseDictionary);
        return geBaseDictionary;
    }

    /**
     * 修改数据
     *
     * @param geBaseDictionary 实例对象
     * @return 实例对象
     */
    @Override
    public GeBaseDictionary update(GeBaseDictionary geBaseDictionary) {
        this.geBaseDictionaryDao.update(geBaseDictionary);
        return this.queryById(geBaseDictionary.getDictionaryId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dictionaryId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dictionaryId) {
        return this.geBaseDictionaryDao.deleteById(dictionaryId) > 0;
    }
}
